<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php 
if(!$_POST)
{
	$adc->setView('list');
	if($adc->getAds())
	{
		$out  = '';
		$types  = $adc->getAdTypes();
		$adcats = $adc->getAdCats();
		$brands = $adc->getAdBrands();
		foreach($adc->getAds() as $item)
		{
			$out .= '<tr class="items">';
			$out .= 	'<td class="first center"><a target="_blank" href="/ad/'.$item->getId().'/">'.$item->getId().'</a></td>';
			$out .= 	'<td>';
			$out .= 		'<input type="hidden" name="item_Id[]" value="'.$item->getId().'" />';
			$out .= 		'<div style="display:none;">'.$item.'</div>';
			$out .= 		'<input class="select_list" type="checkbox" name="selected[]" value="'.$item->getId().'" />';
			$out .= 	'</td>';
			$out .= 	'<td class="nowrap">'.$txt->truncate($item->getTypeTitle(), 20).'<input type="hidden" name="item_TypeId[]" value="'.$item->getTypeId().'" /></td>';
			$out .= 	'<td class="nowrap">'.$txt->truncate($item->getCatTitle(), 20).'<input type="hidden" name="item_CatId[]" value="'.$item->getCatId().'" /></td>';
			$out .= 	'<td class="nowrap">'.$txt->truncate($item->getBrandTitle(), 20).'<input type="hidden" name="item_BrandId[]" value="'.$item->getBrandId().'" /></td>';
			$out .= 	'<td class="nowrap"><a target="_blank" href="?con=2&user='.$item->getUserId().'">'.$item->getUserId().'</a></td>';
			$out .= 	'<td>';
			$out .= 		'<input type="text" name="item_Title[]" class="small" value="'.$item->getTitle().'" maxlength="80" />';
			$out .= 	'</td>';
			$out .= 	'<td>';
			$out .= 		'<input type="text" name="item_TitleEn[]" class="small" value="'.$item->getTitleEn().'" maxlength="80" />';
			$out .= 	'</td>';
			$out .= '<td>';
				$out .= $item->getViewsDetail();
				$out .= ' / ';
				$out .= $item->getViewsList();
				if(($item->getViewsDetail() > 0) && ($item->getViewsList() > 0))
				{ $out .= ' ('.round(($item->getViewsDetail()/$item->getViewsList()),2).' %)'; }
			$out .= '</td>';
			$out .= 	'<td>';
			$out .= 		'<div style="display:none;">'.$item->getIsBuying().'</div>';
			$out .= 		'<input type="checkbox" name="item_IsBuying_'.$item->getId().'" value="1" '.$txt->getIsCheckedHTML($item->getIsBuying(), 1).' />';
			$out .= 	'</td>';
			$out .= 	'<td>';
			$out .= 		'<div style="display:none;">'.$item->getIsNew().'</div>';
			$out .= 		'<input type="checkbox" name="item_IsNew_'.$item->getId().'" value="1" '.$txt->getIsCheckedHTML($item->getIsNew(), 1).' />';
			$out .= 	'</td>';
			$out .= 	'<td>';
			$out .= 		'<div style="display:none;">'.$item->getIsCompleted().'</div>';
			$out .= 		'<input type="checkbox" name="item_IsCompleted_'.$item->getId().'" value="1" '.$txt->getIsCheckedHTML($item->getIsCompleted(), 1).' />';
			$out .= 	'</td>';
			$out .= 	'<td class="nowrap">'.substr($item->getDateCreated(), 0, 10).'</td>';
			$out .= 	'<td class="center">';
			$out .= 		'<a href="?con='.$_REQUEST['con'].'&amp;catId='.$item->getCatId().'&amp;editor=ad&amp;ad='.$item->getId().'"><img title="'.ucfirst($txt->getWord('edit')).'" class="icon command" src="'.SYSICONS_URL.'configure_16.gif" /></a>';
			$out .= 	'</td>';
			$out .= 	'<td>';
			$out .= 		'<div style="display:none;">'.$item->getActive().'</div>';
			$out .= 		$commander->getActivationFieldsObjectAjax($item).'<input type="hidden" name="Active[]" value="'.$item->getActive().'" />';
			$out .= 	'</td>';
			$out .= 	'<td>'.$commander->getArchiveFieldsObjectAjax($item).'<input type="hidden" name="Archived[]" value="'.$item->getArchived().'" />&nbsp;</td>';
			$out .= 	'<td class="last center">';
			if($item->getDeleted() > 0)
			{ $out .= 	'<img title="'.ucfirst($txt->getWord('restore').' '.$txt->getWord('from').' '.$txt->getWord('deleted').' '.$txt->getWord('ads')).'" class="icon command" src="'.SYSICONS_URL.'restore_16.png" onclick="itemRestore('.$item->getId().');" />'; }
			else
			{ $out .= 	'<img title="'.ucfirst($txt->getWord('delete')).'" class="icon command" src="'.SYSICONS_URL.'delete_16.gif" onclick="deleteDialog('.$item->getId().');" />'; }
			$out .= 	'</td>';

			$out .= '</tr>';
		}
	}
	else
	{
		$out  = '<tr class="items">';
		$out .= 	'<td class="first center">0</td>';
		$out .= 	'<td class="center"><input class="select_list" type="checkbox" name="selected[]" value="0" /></td>';
		$out .= 	'<td>'.ucfirst($txt->getWord('no_items')).'</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td>&nbsp;</td>';
		$out .= 	'<td class="last center">&nbsp;</td>';
		$out .= '</tr>';
	}
	echo $out;
}
?>